package com.shanghaionstar.dealersorder.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.TextView;

import com.onstar.cn.framework.annotation.FindViewById;
import com.onstar.cn.framework.base.CommonAdapter;
import com.onstar.cn.framework.base.CommonViewHolder;
import com.onstar.cn.mag.dealer.MaintenanceDealerOrdersEntity;
import com.shanghaionstar.R;

import java.util.List;

public class DealerOrderRecordAdapter extends CommonAdapter<MaintenanceDealerOrdersEntity> {
    private static String TAG = DealerOrderRecordAdapter.class.getSimpleName();
    private Context context;

    public DealerOrderRecordAdapter(List<MaintenanceDealerOrdersEntity> datas, Context context) {
        super(datas, context);
        this.context = context;
    }

    public void setDatas(List<MaintenanceDealerOrdersEntity> datas){
        this.datas = datas;
        notifyDataSetChanged();
    }

    @Override
    public void getView(int position, CommonViewHolder viewHolder) {
        ViewHolder holder = (ViewHolder) viewHolder;
        MaintenanceDealerOrdersEntity orders = datas.get(position);
        holder.tv_type.setText(orders.getPreType());
        holder.tv_dealerName.setText(orders.getStationName());
        holder.tv_carInfo.setText(orders.getLineName());
        holder.tv_bookingName.setText(orders.getName()); //yqt注掉姓名
        if (orders.getRegTime() != null) {
            holder.tv_bookingTime.setText(orders.getRegTime());
        }
        if (TextUtils.isEmpty(orders.getPreStatus()) || "null".equalsIgnoreCase(orders.getPreStatus())) {
            holder.tv_status.setText("——");
        } else {
            holder.tv_status.setText(orders.getPreStatus());
        }
    }

    @Override
    public CommonViewHolder getViewHolder() {
        return new ViewHolder();
    }

    @Override
    public int layoutId() {
        return R.layout.onstar_dealer_book_record_item;
    }

    private class ViewHolder extends CommonViewHolder {
        @FindViewById
        TextView tv_type,tv_status,tv_dealerName,tv_carInfo,tv_bookingName,tv_bookingTime;
    }
}